#!/bin/bash
APP_HOME="/data/server"
APP_NAME="auto"
DIST_JAR="${APP_HOME}/${APP_NAME}".jar
PID_FILE="${APP_NAME}".pid

JAVA_PID=""
if [ -f "${PID_FILE}" ];then
    cd "${APP_HOME}/script" && sh "./shutdown.sh"
fi
JAVA=/usr/local/jdk1.8.0_131/bin/java

JAVA_OPTS="-Dfile.encoding=utf-8 -Xms512M -Xmx512M"
JAVA_OPTS="${JAVA_OPTS}"" -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=""${LOG_DIR}"

nohup ${JAVA} -jar ${JAVA_OPTS} "${DIST_JAR}" --spring.profiles.active=prod > /dev/null 2>&1 &
JAVA_PID=$!
echo "${JAVA_PID}" > "${PID_FILE}"
echo "${APP_NAME}"" started, pid: ""${JAVA_PID}"
